package com.java.compilation.helper;

import java.util.HashMap;
import java.util.Map;

public class IDGenerator {

    private Map<Kind, Integer> iDMap = new HashMap<>();

    private static int label = 0;

    public int getAndIncr(Kind kind) {
        Integer result = iDMap.getOrDefault(kind, 0);
        iDMap.put(kind, result + 1);
        return result;
    }

    public void clear(Kind kind) {
        iDMap.remove(kind);
    }

    public static int getAndIncrLabel() {
        return label++;
    }
}
